'use strict';

//导入http模块；
var http = require('http');
var url = require('url');
//创建http server， 并传入回调函数；
var server = http.createServer(function (request, response) {
    //回掉函数接收request恶化response对象
    //获得HTTP请求的method和url
    console.log(request.method + ':' + request.url);
    //将HTTP响应200写入response，同时设置Content-type为text/html
    response.writeHead(200, { 'Content-Type': 'text/html' });
    //将http响应的tml内容写入response
    response.end('<h>Hello World</h1>');
});
server.listen(8080);
console.log('Serevr is running at http://127.0.0.1:8080/');
console.log(url.parse('http://user:pass@host.com:8080/path/to/file?query=string#hash'));